package com.mutual.assistance.task.converter;


import com.mutual.assistance.task.model.dto.*;
import com.mutual.assistance.task.model.po.*;
import com.mutual.assistance.task.model.vo.AddTaskCommentParamsVO;
import com.mutual.assistance.task.model.vo.CreateTaskParamsVO;
import com.mutual.assistance.task.model.vo.TaskAuditParamsVO;
import com.mutual.assistance.task.model.vo.UpdatePreTaskParamsVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * @author chenyuxin
 * @version 1.0
 * @description 任务实体类之间的转换
 * @date 2023/4/28 22:36
 */
@Mapper(componentModel = "spring")
public interface TaskConverterParams {

    @Mapping(target = "status", constant = "002002")
    @Mapping(target = "recipient", ignore = true)
    @Mapping(target = "receiveTime", ignore = true)
    @Mapping(target = "publisher", ignore = true)
    @Mapping(target = "publishTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "offlineDate", ignore = true)
    @Mapping(target = "id", ignore = true)
    TaskPublishPrePO createTaskParamsVO2TaskPublishPrePO(CreateTaskParamsVO createTaskParamsVO);

    @Mapping(target = "publisher", ignore = true)
    TaskPrePublishPersonDTO taskPublishPrePO2TaskPrePublishPersonDTO(TaskPublishPrePO taskPublishPrePO);

    List<TaskPrePublishPersonDTO> taskPublishPrePO2TaskPrePublishPersonDTOList(List<TaskPublishPrePO> taskPublishPrePO);

    @Mapping(target = "publisher", ignore = true)
    TaskPrePublishDTO taskPublishPrePO2TaskPrePublishDTO(TaskPublishPrePO taskPublishPrePO);

    List<TaskPrePublishDTO> taskPublishPrePO2TaskPrePublishDTOList(List<TaskPublishPrePO> taskPublishPrePO);

    TaskPublishPO taskPublishPrePO2TaskPublishPO(TaskPublishPrePO taskPublishPrePO);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "auditTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "auditPeople", ignore = true)
    TaskAuditPO taskAuditParamsVO2TaskAuditPO(TaskAuditParamsVO taskAuditParamsVO);

    @Mapping(target = "tags", ignore = true)
    @Mapping(target = "type", ignore = true)
    @Mapping(target = "status", constant = "002002")
    @Mapping(target = "recipient", ignore = true)
    @Mapping(target = "receiveTime", ignore = true)
    @Mapping(target = "publisher", ignore = true)
    @Mapping(target = "publishTime", ignore = true)
    @Mapping(target = "offlineDate", ignore = true)
    @Mapping(target = "id", source = "taskId")
    @Mapping(target = "credit", ignore = true)
    TaskPublishPrePO updatePreTaskParamsVO2TaskPublishPrePO(UpdatePreTaskParamsVO updatePreTaskParamsVO);

    TaskPublishPrePO taskPublishPO2TaskPublishPrePO(TaskPublishPO taskPublishPO);

    UserDTO userRemote2UserDTO(UserRemote userRemote);

    @Mapping(target = "commentDTOS", ignore = true)
    @Mapping(target = "publisher", ignore = true)
    TaskPublishDTO taskPublishPO2TaskPublishDTO(TaskPublishPO taskPublishPO);

    List<TaskPublishDTO> taskPublishPO2TaskPublishDTOList(List<TaskPublishPO> taskPublishPOList);

    TaskPublishHistoryPO taskPublishPO2TaskPublishHistoryPO(TaskPublishPO taskPublishPO);

    @Mapping(target = "updateTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "taskId", source = "id")
    @Mapping(target = "star", ignore = true)
    @Mapping(target = "publisherAppraise", ignore = true)
    @Mapping(target = "createTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "id", ignore = true)
    TaskAppraisePO taskPublishPO2TaskAppraisePO(TaskPublishPO taskPublishPO);

    @Mapping(target = "updateTime", expression = "java(java.time.LocalDateTime.now())")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", expression = "java(java.time.LocalDateTime.now())")
    CommentPO addTaskCommentParamsVO2CommentPO(AddTaskCommentParamsVO addTaskCommentParamsVO);

    @Mapping(target = "user", ignore = true)
    CommentDTO commentPO2CommentDTO(CommentPO commentPO);
    List<CommentDTO> commentPO2CommentDTOList(List<CommentPO> commentPOList);

    @Mapping(target = "publisher", ignore = true)
    @Mapping(target = "taskId", source = "id")
    @Mapping(target = "star", ignore = true)
    @Mapping(target = "publisherAppraise", ignore = true)
    TaskHistoryDTO taskPublishHistoryPO2TaskHistoryDTO(TaskPublishHistoryPO taskPublishHistoryPO);

    List<TaskHistoryDTO> taskPublishHistoryPO2TaskHistoryDTOList(List<TaskPublishHistoryPO> taskPublishHistoryPOList);


}

